// #pragma once

#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
// #include "main.h"
#include "esp_wifi.h"
// #include "esp_netif_types.h"

#include "lwip/err.h"
#include "lwip/sys.h"

typedef struct
{
    int ssid_len;
    uint8_t password[64];   //设置在blufi BLUFI事件接收password里
    uint8_t bssid[6];       //设置在WiFi  WIFI 事件连接事件里
    uint8_t ssid[32];       //设置在WiFi  WIFI 事件连接事件里
    bool isConnected;       //到处有
    bool isUserDisconnetAP;
    esp_netif_ip_info_t ip_info;    //设置在wifi IP事件里
}_Cur_wifi_info;

typedef struct 
{
    wifi_ap_record_t *ap_list;
    uint16_t apCount;
}_Cur_wifi_list;



static const EventBits_t  WIFI_CONNECTED_BIT = BIT0;
static const EventBits_t  WIFI_FAIL_BIT = BIT1;
static const EventBits_t  WIFI_SCAN_FINISH_BIT = BIT2;

extern const char *TAG_WIFI;
extern EventGroupHandle_t wifi_event_group;
extern wifi_config_t sta_config;
extern _Cur_wifi_info cur_wifi_info;
extern _Cur_wifi_list cur_wifi_list;

void init_wifi();
void connect_wifi();
void disconnect_wifi();
void wifi_scan_start();
void wifi_scan_stop();
void wifi_scan_get_res();
